/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fiad.gui.components;

import java.awt.Color;
import javax.swing.JList;

/**
 *
 * @author MJ
 */
public class MyJList extends JList {
    private boolean enabled = true;

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        this.enabled = enabled;

        if (enabled) {
            setBackground(Color.white);
        } else {
            setBackground(new Color(244, 244, 244));
        }
    }

    @Override
    public void setSelectedIndex(int index) {
        if (enabled) {
            super.setSelectedIndex(index);
        }
    }

    @Override
    public void setSelectedIndices(int[] indices) {
        if (enabled) {
            super.setSelectedIndices(indices);
        }
    }

    @Override
    public void setSelectedValue(Object anObject, boolean shouldScroll) {
        if (enabled) {
            super.setSelectedValue(anObject, shouldScroll);
        }
    }

    @Override
    public void addSelectionInterval(int anchor, int lead) {
        if (enabled) {
            super.addSelectionInterval(anchor, lead);
        }
    }
}
